home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-16 | 6.9 KB | 244 lines | [TEXT/MPS ] |
- ;_________________________________________________________________________
- ;
- ; dmz.a
- ;_________________________________________________________________________
- ;
- ; DTS Code Sample
- ;
- ; ©1990 Apple Computer, Inc.
- ;
- ; 3/7/90 - 10/26/90 pvh
- ;
- ;_________________________________________________________________________
-
- PRINT PUSH,OFF ; don't print any of this stuff
-
- INCLUDE 'QuickEqu.a'
- INCLUDE 'ToolEqu.a'
- INCLUDE 'SysEqu.a'
- INCLUDE 'Traps.a'
- INCLUDE 'ATalkEqu.a'
- INCLUDE 'SysErr.a'
-
- PRINT POP ; restore the PRINT options
-
- ;--------------------------------------
- ; myVBLSpinInstall
- ;
- ; 10/90 pvh
- ;
- ; I hated the ToolLib spinning cursor routines enough to make up my own. Those routines
- ; are fine if you base your spinning cursor off a tight loop where you can continuously call the
- ; routines to actually spin the cursor. In my case that library was not ideal, so instead
- ; I just threw ('slapped' might be the better term) together a VBL task that spins the cursor
- ; instead (ala MacApp).
- ;
- ; This routine & the clean up routine that follows are pretty mcuh self explanatory. 4 cursors
- ; are preloaded & locked so they'll be sure to be available when the VBL task is called. The
- ; task is set up and moved into the application's heap. The task itself checks a locally saved
- ; variable for the cursor ID, loads in that cursor and sets that cursor as the current one if
- ; the cursor state is not currently busy (by checking CrsrBusy).
- ;
- ; When the task finishes, global references to the VBL task are used in the clean up routine
- ; (stopAndRemoveSpinningCursor) to remove the task & associated buffers. The cursors are also
- ; released from memory here.
- ;
- ; 10/16/90 pvh
- ;
- ; gMac was imported originally to help support color cursors within this task, but that endeavor
- ; was turning out to be too much of a hack (even for me), so it's staying around as a remanant of
- ; that failed attempt just to mark another one of my failures. :-)
-
- spinGlobals RECORD 0 ; this is our global data storage
- gtheTaskPtr DS.L 1 ; pointer to hold task itself
- gtheVBLPtr DS.L 1 ; pointer for VBL task record
- ENDR
-
- EXPORT (sg):DATA
-
- sg DS spinGlobals ; globals for spin cursor
-
-
- myVBLSpinInstall PROC EXPORT
- IMPORT gMac : DATA
-
- StackFrame RECORD {A6Link},DECR ; build a stack frame record
- ParamBegin EQU * ; start listing parameters here
- ParamSize EQU ParamBegin-* ; size of all the passed parameters
- RetAddr DS.L 1 ; place holder for return address
- A6Link DS.L 1 ; place holder for A6 link
- taskSize DS.L 1 ; size of our VBL task
- curses DS.L 4 ; handle for our cursor
- cursType DS.L 1
- LocalSize EQU * ; size of all the local variables
- ENDR
-
- WITH StackFrame, SysEnvRec ; cover our local stack frame
- LINK A6,#LocalSize ; allocate our local stack frame
-
- ; pre-load in the resources to make sure they are around
- CLR.L -(sp) ; make space on the stack for result
- MOVE.L #'CURS', cursType(a6) ; another remanant from color stuff (don't ask)
- MOVE.L cursType(a6), -(sp)
- MOVE #1001, -(sp)
- _GetResource
- MOVE.L (sp)+, curses(a6)
- MOVE.L curses(a6), a0
- _HLock
-
- CLR.L -(sp) ; make space on the stack for result
- MOVE.L cursType(a6), -(sp)
- MOVE #1002, -(sp)
- _GetResource
- MOVE.L (sp)+, curses+4(a6)
- MOVE.L curses+4(a6), a0
- _HLock
-
- CLR.L -(sp) ; make space on the stack for result
- MOVE.L cursType(a6), -(sp)
- MOVE #1003, -(sp)
- _GetResource
- MOVE.L (sp)+, curses+8(a6)
- MOVE.L curses+8(a6), a0
- _HLock
-
- CLR.L -(sp) ; make space on the stack for result
- MOVE.L cursType(a6), -(sp)
- MOVE #1004, -(sp)
- _GetResource
- MOVE.L (sp)+, curses+12(a6)
- MOVE.L curses+12(a6), a0
- _HLock
-
- BRA.S theTaskEnd
-
- ; actual VBL Task
- theTaskBegin
- MOVEM.L a0-a6/d0-d7, -(sp) ; save
- BRA.S afterStorage
- A5Storage
- DC.L 0
- afterStorage
- ; reset the vbl count
- MOVE.W #5, vblCount(a0)
-
- ; restore A5 for globals we may have
- LEA A5Storage, a0
- MOVE.L (a0), a5
- BRA.S xxx
- cursorStorage
- DC.W $03E9 ; storage for cursor type, start with first cursor ID
- xxx
- LEA cursorStorage, a0
- ADD.W #1, (a0)
- MOVE.W (a0), d0
- CMP.W #1005, d0
- BLT.S doCursor
-
- MOVE.W #1001, (a0) ; start over with cursor type #1001
- MOVE.W #1001, d0 ; it needs to be in d0
- doCursor
- CLR.L -(a7) ; make some space for return
- MOVE.W d0, -(a7) ; move in cursor type
- _GetCursor
- MOVE.L (a7)+, a0 ; move handle into a0
- BEQ.S vblExit ; test for nil handle
- tst.b CrsrBusy ; cursor drawing as we speak? then split.
- BNE.S vblExit
- MOVE.L (a0), -(a7) ; deref and push on stack
- _SetCursor
- vblExit
- MOVEM.L (sp)+, a0-a6/d0-d7 ; restore
- rts
- theTaskEnd
-
- ; VBL initialization code
- LEA theTaskEnd, a0 ; address of tail of task
- LEA theTaskBegin, a1 ; head of task
- MOVE.L a0, d0 ; get size of task
- SUB.L a1, d0
- MOVE.L d0, taskSize(a6)
-
- LEA A5Storage, a0 ; put current A5 into our storage area in code
- MOVE.L CurrentA5, (a0)
-
- ; set up VBL record
- MOVE.L #vblPhase+2, d0 ; size of VBLTask
- _NewPtr
- MOVE.L a0, sg.gtheVBLPtr(a5)
-
- ; setup block of memory to hold task itself (in our heap, not the System heap)
- MOVE.L taskSize(a6), d0
- _NewPtr
- MOVE.L a0, sg.gtheTaskPtr(a5)
-
- ; move the task code into block in heap
- LEA theTaskBegin, a0 ; head of task
- MOVE.L sg.gTheTaskPtr(a5), a1
- MOVE.L taskSize(a6), d0
- _BlockMove
-
- MOVE.L sg.gtheTaskPtr(a5), a1
- MOVE.L sg.gtheVBLPtr(a5), a0
- MOVE.L a1, vblAddr(a0) ; a1 contains address of moved TheTask
- MOVE.W #vType, qType(a0)
- MOVE.W #10, vblCount(a0)
- MOVE.W #4, vblPhase(a0) ; whatever
- _VInstall
-
- Exit UNLK A6 ; destroy the link
- MOVEA.L (SP)+,A0 ; pull off the return address
- ADDA.L #ParamSize,SP ; strip all of the caller's parameters
- JMP (A0) ; return to the caller
-
- ENDP
-
- ;--------------------------------------
- ; this routine disposes of the VBL spinning cursor task & removes memory allocated for the
- ; task. also unloads the cursors from the heap.
-
- stopAndRemoveSpinningCursor PROC EXPORT
-
- IMPORT gtheTaskPtr : DATA
- IMPORT gtheVBLPtr : DATA
-
- MOVE.L sg.gtheVBLPtr, a0
- _VRemove
-
- MOVE.L sg.gtheVBLPtr, a0
- _DisposPtr
-
- MOVE.L sg.gtheTaskPtr, a0
- _DisposPtr
-
- ; unload the cursors
- CLR.L -(sp)
- MOVE.L #'CURS', -(sp)
- MOVE #1001, -(sp)
- _GetResource
- _ReleaseResource
-
- CLR.L -(sp)
- MOVE.L #'CURS', -(sp)
- MOVE #1002, -(sp)
- _GetResource
- _ReleaseResource
-
- CLR.L -(sp)
- MOVE.L #'CURS', -(sp)
- MOVE #1003, -(sp)
- _GetResource
- _ReleaseResource
-
- CLR.L -(sp)
- MOVE.L #'CURS', -(sp)
- MOVE #1004, -(sp)
- _GetResource
- _ReleaseResource
-
- rts
-
- ENDP
- ;--------------------------------------
- END ; end of this source file
-